package br.com.firula.to;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name="usuario")
@Inheritance(strategy=InheritanceType.JOINED)
public class UsuarioTO extends UsuarioBaseTO{

	private static final long serialVersionUID = 1L;

	@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinTable(name="rel_usuario_torcida",
        joinColumns=@JoinColumn(name="idUsuario", nullable = false, referencedColumnName="id"),
        inverseJoinColumns=@JoinColumn(name="idTorcida", nullable = false, referencedColumnName="id"))
	private List<TorcidaTO> torcidas;

	@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinTable(name="rel_usuario_bolao_apostas",
        joinColumns=@JoinColumn(name="idUsuario", nullable = false, referencedColumnName="id"),
        inverseJoinColumns=@JoinColumn(name="idBolao", nullable = false, referencedColumnName="id"))
	private List<BolaoTO> bolaoApostas;

	@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinTable(name="rel_usuario_bolao_vencedores",
        joinColumns=@JoinColumn(name="idUsuario", nullable = false, referencedColumnName="id"),
        inverseJoinColumns=@JoinColumn(name="idBolao", nullable = false, referencedColumnName="id"))
	private List<BolaoTO> bolaoVencedores;

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "usuario")
	private List<ComentarioTO> comentarios;

	@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinTable(name="rel_usuario_promocao_participantes",
        joinColumns=@JoinColumn(name="idUsuario", nullable = false, referencedColumnName="id"),
        inverseJoinColumns=@JoinColumn(name="idPromocao", nullable = false, referencedColumnName="id"))
	private List<PromocaoTO> promocaoParticipantes;

	@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinTable(name="rel_usuario_promocao_vencedores",
        joinColumns=@JoinColumn(name="idUsuario", nullable = false, referencedColumnName="id"),
        inverseJoinColumns=@JoinColumn(name="idPromocao", nullable = false, referencedColumnName="id"))
	private List<PromocaoTO> promocaoVencedores;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "idTime", nullable = false)
	private TimeTO time;

	@Transient
	private Long timeId;

	public List<TorcidaTO> getTorcidas() {
		return torcidas;
	}

	public void setTorcidas(List<TorcidaTO> torcidas) {
		this.torcidas = torcidas;
	}

	public List<BolaoTO> getBolaoApostas() {
		return bolaoApostas;
	}

	public void setBolaoApostas(List<BolaoTO> bolaoApostas) {
		this.bolaoApostas = bolaoApostas;
	}

	public List<BolaoTO> getBolaoVencedores() {
		return bolaoVencedores;
	}

	public void setBolaoVencedores(List<BolaoTO> bolaoVencedores) {
		this.bolaoVencedores = bolaoVencedores;
	}

	public List<ComentarioTO> getComentarios() {
		return comentarios;
	}

	public void setComentarios(List<ComentarioTO> comentarios) {
		this.comentarios = comentarios;
	}

	public List<PromocaoTO> getPromocaoParticipantes() {
		return promocaoParticipantes;
	}

	public void setPromocaoParticipantes(List<PromocaoTO> promocaoParticipantes) {
		this.promocaoParticipantes = promocaoParticipantes;
	}

	public List<PromocaoTO> getPromocaoVencedores() {
		return promocaoVencedores;
	}

	public void setPromocaoVencedores(List<PromocaoTO> promocaoVencedores) {
		this.promocaoVencedores = promocaoVencedores;
	}

	public TimeTO getTime() {
		return time;
	}

	public void setTime(TimeTO time) {
		this.time = time;
	}

	public Long getTimeId() {
		return timeId;
	}

	public void setTimeId(Long timeId) {
		this.timeId = timeId;
	}

}

